***
* Nielsen et al AJPS Replication
***
***************************************************
** Main Model: aid shocks with full covariate set
***************************************************
* This is their Table 1, on page 226

use cwdata, clear

quietly relogit prio aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ColdWar _spline1 _spline2 _spline3, cl(countrynum)
*quietly xtlogit prio aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ColdWar _spline1 _spline2 _spline3, fe
keep if e(sample)

ccode countryname, from(cty) to(cow) gen(ccode)
replace ccode=439 if countryname=="Burkina Faso (Upper Volta)"
replace ccode=484 if countryname=="Congo"
replace ccode=630 if countryname=="Iran (Persia)"
replace ccode=360 if countryname=="Rumania"
replace ccode=365 if countryname=="Russia (Soviet Union)"
replace ccode=780 if countryname=="Sri Lanka (Ceylon)"
replace ccode=640 if countryname=="Turkey/Ottoman Empire"
replace ccode=2 if countryname=="United States of America"

replace ccode=370 if countryname=="Belarus (Byelorussia)"
replace ccode=811 if countryname=="Cambodia (Kampuchea)"
replace ccode=490 if countryname=="Congo, Democratic Republic of (Zaire)"
replace ccode=255 if countryname=="German Federal Republic"
replace ccode=325 if countryname=="Italy/Sardinia"
replace ccode=552 if countryname=="Zimbabwe (Rhodesia)"

merge m:1 ccode using gattlist.dta, gen(m1)
drop if m1==2
merge m:1 ccode using wtolist.dta, gen(m2)
drop if m2==2

gen gatt = year>=gattjoin
gen wto = year>=wtojoin
gen gattwto = gatt==1 | wto==1
gen study = ""
foreach n in orig noth fe time fet ct yfe cyfe {
gen method_`n' = ""
gen dv_`n' = ""
gen b_gatt_`n' = .
gen se_gatt_`n'= .
gen pval_gatt_`n' = .
gen lo_gatt_`n'=.
gen hi_gatt_`n'=.
gen N_gatt_`n'=.
}
gen studynum=.
gen timetrend=""

qui do gatt.do
local ii = 1
* relogit, column 1
relogit prio gattwto aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv ///
   lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ///
   ColdWar _spline1 _spline2 _spline3, cl(countrynum)
gatt `ii' orig
relogit prio gattwto aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv ///
   lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ColdWar , cl(countrynum)
gatt `ii' noth
relogit prio gattwto aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv ///
  lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ColdWar ///
  _spline1 _spline2 _spline3, cl(countrynum)
gatt `ii' time
replace studynum = `ii' if _n==`ii'  
replace timetrend = "splines" if _n==`ii'   

local ii=`ii'+1

** Fixed Effects, column 2
xtlogit prio gattwto aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv ///
 lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ColdWar ///
 _spline1 _spline2 _spline3, fe
gatt `ii' orig
xtlogit prio gattwto aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv ///
  lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ColdWar , re
gatt `ii' noth
xtlogit prio gattwto aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv ///
  lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ///
  ColdWar , fe
gatt `ii' fe
xtlogit prio gattwto aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv ///
  lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ColdWar ///
  _spline1 _spline2 _spline3, re
gatt `ii' time
xtlogit prio gattwto aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv ///
  lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ///
  ColdWar _spline1 _spline2 _spline3 , fe
gatt `ii' fet
logit prio gattwto aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv ///
  lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ///
  ColdWar _spline1 _spline2 _spline3 i.ccode#c.year, cl(ccode)
gatt `ii' ct
clogit prio gattwto aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv ///
  lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ///
   , group(year) vce(cl year)
gatt `ii' yfe
xtreg prio gattwto aidshock11 aidshock11pos lPTSave_filled lassassinbanks lriotsbanks lstrikesbanks ldemonstrationsbanks linfantmort lnciv ///
  lpartautocracy lpartdemocracy lfactionaldemoc lfulldemocracy lln_rgdpc  lln_population  loil linstab ethfrac relfrac ncontig logmtn ///
  ColdWar i.year , fe vce(cl ccode)
gatt `ii' cyfe
replace studynum = `ii' if _n==`ii'   
replace timetrend = "splines" if _n==`ii'   

local ii=`ii'+1

replace study = "Nielsen et. al." if studynum~=. 	

keep study-timetrend
drop if studynum==.
compress
save nielsenetal.dta , replace
